**# Step 1
/*---------------------------------------------------------------------
Select and label relevant variables from the following original data:
1) ACS data
2) county data
3) PLACES data
---------------------------------------------------------------------*/

do "code\management\dst-data01_acs_pop_and_housing_basics_clean.do"
do "code\management\dst-data01_acs_educ_attainment_clean.do"
do "code\management\dst-data01_acs_marital_status_clean.do"
do "code\management\dst-data01_acs_hh_size_clean.do"
do "code\management\dst-data01_acs_health_ins_coverage_clean.do"
do "code\management\dst-data01_acs_employ_status_clean.do"

do "code\management\dst-data01_counties_2020_clean.do"

do "code\management\dst-data01_places_2020_release_eastern_central_clean.do"
do "code\management\dst-data01_places_2020_release_central_mountain_clean.do"
do "code\management\dst-data01_places_2020_release_mountain_pacific_clean.do"
do "code\management\dst-data01_places_2021_release_eastern_central_clean.do"
do "code\management\dst-data01_places_2021_release_central_mountain_clean.do"
do "code\management\dst-data01_places_2021_release_mountain_pacific_clean.do"

**# Step 2
/*--------------------------------------------------------------------------------------------------------------------------------------
1) Combine the ACS data.
2) Calculate the sunrise time, sunset time, and the sunlight duration for the centroid of each county included in the PLACES data. 
--------------------------------------------------------------------------------------------------------------------------------------*/

do "code\management\dst-data02_acs_combine.do"

do "code\management\dst-data02_solar_county_daily.do"
do "code\management\dst-data02_solar_county_avg.do"

**# Step 3
/*-----------------------------------------------------------------------------------------
Merge PLACES data with:
1) the combined ACS data;
2) the sunlight duration data. 
The resulting data are ready for analysis.
-----------------------------------------------------------------------------------------*/

do "code\management\dst-data03_for_estimation_eastern_central.do"
do "code\management\dst-data03_for_estimation_central_mountain.do"
do "code\management\dst-data03_for_estimation_mountain_pacific.do"

**# Step 4
/*-------------------------------------------------------------------------------------------------
Further process the data:
1) Merge individual datasets into one single dataset.
2) Generate new variables that can be used for later estimation.
3) Keep census tracts' centroids that are within X miles of the time zone borders. Here, X = 250
The resulting data are ready for estimation. 
-------------------------------------------------------------------------------------------------*/

do "code\management\dst-data04_for_estimation_within_250_miles.do"

exit